package club.emergency.wechat.persistence.manager;

import club.emergency.wechat.model.authorization.Authorization;
import club.emergency.wechat.model.manager.Manager;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author jifujun
 * @since 2018-11-16
 */
public interface ManagerMapper extends BaseMapper<Manager> {

    /**
     * 在角色和后台人员中间表中查询某个用户所拥有的角色
     *
     * @param managerId 后台用户id
     * @return 角色id列表
     */
    @Select("SELECT role_id from role_has_manager where manager_id = #{managerId}")
    List<Long> queryRoleIdFromRHMByManagerId(@Param("managerId") Long managerId);

    /**
     * 在权限和角色中间表中根据角色id查询所有的权限id
     *
     * @param roleList 角色列表
     * @return 权限id列表
     */
    @Select("SELECT authorization_id from authorization_has_role where role_id in #{roleList}")
    List<Long> queryAuthorizationIdFromAHRByRoleIds(@Param("roleList") List<Long> roleList);

    /**
     * 根据权限id查询权限详情
     *
     * @param authorizationIdList 权限id列表
     * @return 权限列表
     */
    List<Authorization> queryAuthorizationByAuthorizationIds(@Param("authorizationIdList") List<Long> authorizationIdList);
}
